/**
 * 定义天数据模块
 */
(function(window, angular, undefined){
	var module = angular.module('water.apps.WasteGas.ReportData.avgStatistics.weekDataManager', ['water.apps.WasteGas.ReportData.avgStatistics.minDataManager',
	                                                                                  'water.common.dateUtil','water.entity.monitorData']);
	
	module.controller('reportAvgStatisticsWeekController',function($rootScope,$scope,$controller,$dateUtil,$monitorDataService,$DataReportService){

		var control = $controller("reportAvgStatisticsMinuteController",{$scope:$scope});
		
		$scope.dataAPIName = "dayListGetter";
		$scope.dataExportAPIName = "exportDayExcel";
		/**
		 * 开始时间
		 */
		$scope.startDate;
		/**
		 * 结束时间
		 */
		$scope.endDate;
		$scope.yearlist=[];
		var currentYear=(new Date()).getFullYear();
		
		for(var i=0;i<4;i++){
			$scope.yearlist.push({
				name:currentYear-i+"年",
				value:currentYear-i+""
			});
		}
		$scope.changeYear = function(year){
			$scope.weeklist = $DataReportService.getYearWeek(year);
			$scope.selectWeek= $scope.weeklist[0].value;
			for(var i=0;i<$scope.weeklist.length;i++){
				var week = $scope.weeklist[i];
				if(week.today){
					$scope.selectWeek = week.value;
				}
			}
		}
		$scope.selectYear=currentYear+"";	
		$scope.changeYear($scope.selectYear);
		/**
		 * 获取查询参数,重写，跟基类不一样的地方在于，这里起始和结束时间直接取的是控件的值
		 * 而基类是通过选择小时，然后拼接
		 */
		$scope.getQueryObject = function(){
			var parmsStr = $scope.selectedModel.parmToChecksStr;
			var queryObject = {
					"MN":$scope.selectedModel.MN,
					"PARMS":parmsStr,
					"START":$scope.selectWeek.split(",")[0] + " 00:00:00",
					"END":$scope.selectWeek.split(",")[1] + " 23:59:59"
				};
			return queryObject;
		}
		/**
		 * 初始化
		 */
		function _init(){
			var endDate = new Date();
			var startDate = $dateUtil.addDay(endDate,-7)
			$scope.startDate = $dateUtil.formatDate(startDate,'yyyy-MM-dd');
			$scope.endDate = $dateUtil.formatDate(endDate,'yyyy-MM-dd');
		}
		_init();
		
	});
}(window, angular));	